import request from "@/utils/request";
import AES from '@/utils/crypto'

const urlPrefix = "manager"


export function login(username, password) {
    password = AES.encrypt(password);
    return request({
        url: "/login",
        method: "post",
        params: {
            username: username,
            password: password
        }
    })
}

export function queryUsers(page, size, keyword) {
    return request({
        url: urlPrefix + "/list",
        method: "get",
        params: {
            page: page,
            size: size,
            keyword: keyword
        }
    })
}

export function toSuper(id) {
    return request({
        url: urlPrefix + "/toSuper",
        method: "post",
        params: {
            id: id
        }
    })
}

export function deleteUser(id) {
    return request({
        url: urlPrefix + "/delete",
        method: "delete",
        params: {
            id: id
        }
    })
}

export function addUser(userMsg) {
    return request({
        url: urlPrefix + "/add",
        method: "post",
        params: {
            ...userMsg
        }
    })
}

export function quit() {
    return request({
        url: "/logoutProcess",
        method: "get"
    })
}

export function getUserInfo() {
    return request({
        url: "/getUserInfo",
        method: "get"
    })
}
